﻿using System;
using System.Collections.Generic;
using System.Diagnostics.PerformanceData;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;

namespace _01HelloWorld//命名空间
{
    class Program
    {
        static void Main(string[] args)
        {
            //#region //简单计算器
            /*
            float num1, num2, result;
            Console.WriteLine("请输入数字a:");
            //读取键盘输入
            num1 =float.Parse(Console.ReadLine());
            Console.WriteLine("请输入数字b:");
            //读取键盘输入
            num2 = int.Parse(Console.ReadLine());
            result = num1 + num2;
            //Console.WriteLine("A因子:{0},B因子{1}", num1, num2);
            //Console.WriteLine("结果是{0}",result);//第一种
            //Console.WriteLine($"结果是{result}");//第二种
            Console.WriteLine("结果是:" + result);//第三种
            */
            /* #endregion
             char c = '中';
             Console.WriteLine("char占{0}字节", sizeof(char));
             Console.WriteLine("char最大值是{0}", (int)char.MaxValue);
             Console.WriteLine(c);*/
            //&&于都是真
            /*char sex = '男';
            if (sex=='男')
                 Console.WriteLine("去男厕所"); 
            else  Console.WriteLine("去女厕所");*/
            /*float price = 100;
            bool isVIP = false;
            string country="中国";
            if (isVIP == true)
            {
                if (country == "中国")
                    price *= 0.5f;
                else
                    price *= 0.8f;
                Console.WriteLine(price);
            }*/
            /*Console.WriteLine("请输出年/月/日：");
                 string str = Console.ReadLine();
             char[] sepator = { '/' };
             string[] strArr = str.Split(sepator);
             int month = int.Parse(strArr[1]);//月
             int year=int.Parse(strArr )
             int sum = 0;
             //Console.WriteLine(strArr[0]);
             //Console.WriteLine(strArr[1]);
             //Console.WriteLine(strArr[2]);
             switch (month-1)
             {
                 case 1:
                     sum = 31;
                     break;
                 case 2:
                     sum = 31 + 28;
                     break;
             }
             //判断闰年
             if (year %400==0||(year %4==0&&))*/


            //数组
            //声明方式一
            /*int[] monthArr = new int[12];
            //访问数组的每一个元素方法一
            for (int i=0; i<monthArr.Length;i++)
            { 
                Console.WriteLine(monthArr[i]); 
            }
            //访问方式二
            //只能读不能修改值
            foreach(int num in monthArr)
            {
                Console.WriteLine(num);
            }*/
            //声明方式二
            /*int[] bymonthDayArr = new int[13]{0,31,28,31,30,31,30,31,31,30,31,30,31};
           // foreach (var daynum in bymonthDayArr)
            //{
              //  Console.WriteLine(daynum);
            //}
            //Console.WriteLine("请输出年/月/日：");
            string str = "2020/3/5";
             char[] sepator = { '/' };
             string[] strArr = str.Split(sepator);
            int year = int.Parse(strArr[1]);//年
            int month = int.Parse(strArr[2]);//月
            int day = int.Parse(strArr[3]);//日
            int sum = 0;
            for (int i = 1; i < month; i++)
            {
                sum += bymonthDayArr[i];
            }
            sum += day;
            Console.WriteLine($"这是一年中的第{sum}天");*/
            //二维数组
            /*int[,] nineBoxArr = {
            {4,9,2},
            {3,5,7},
            {8,1,6}
            };
            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    Console.WriteLine(nineBoxArr[i, j] + "");
                }
                Console.WriteLine();
            }*/

         /*Console.WriteLine("输入你的出生年月日");
         int bornYear = Convert.ToInt32(Console.ReadLine());
         int bornYue = Convert.ToInt32(Console.ReadLine());
         int bornRi = Convert.ToInt32(Console.ReadLine());
         int nowYear = Convert.ToInt32(DateTime.Now.Year.ToString());
         int nowYue = Convert.ToInt32(DateTime.Now.Month.ToString());
         int nowRi = Convert.ToInt32(DateTime.Now.Day.ToString());
        int[] runNian = new int[] { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };//闰年的每月
        int[] pingNian = new int[] { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };//平年的每月
        int sum = 0;
        int days = 0;
        int sus = 0;
        if (bornYear % 4 == 0 && bornYear % 100 != 0 || bornYear % 400 == 0)//闰年的条件
        {
            for (int i = 0; i < bornYue - 1; i++)
            {
                days += runNian[i];
            }
            days = days + bornRi;//闰年出生那一年，从1月1日到你出生那天有多少天
        }
        else
        {
            for (int i = 0; i < bornYue - 1; i++)
            {
                days += pingNian[i];
            }
            days = days + bornRi;//平年出生那一年，从1月1日到你出生那天有多少天
        }
 for (int i = bornYear; i < nowYear; i++) //从出生那一年到今年的总天数
        {
            if (i % 4 == 0 && i % 100 != 0 || i % 400 == 0)
            {
                sum += 366;  //闰年+366
            }
            else
            {
                sum += 365;//平年+365
            }

        }
        if (nowYear % 4 == 0 && nowYear % 100 != 0 || nowYear % 400 == 0)//确定今年是平年闰年
        {
            for (int i = 0; i < nowYue - 1; i++)
            {
                sus += runNian[i];
            }
            sus += nowRi;
        }

        else
        {
            for (int i = 0; i < nowYue - 1; i++)
            {
                sus += pingNian[i];
            }
            sus += nowRi;
        }

        sum = sum + sus - days;
        Console.WriteLine("你从出生到现在活了：" + sum + "天");
        }*/
        Grid(3);
    }
        static void Grid(int n)
        {
                    int[,] N=new int[n,n];
                int row=n/2,col=n-1;
                N[row,col]=n*n;
                for(int i=n*n-1;i>=1;i--)
                {
                    int r=(row+1)%n;
                    int c=(col+1)%n;
                    if(N[r,c]==0)
                    {
                        N[r,c]=i;
                    }
 
                    else
                    {
                        r=row;
                        c=col-1;
                        N[r,c]=i;
                    }
                    row=r;
                    col=c;
                }
                    Console.WriteLine("{0} {1} {2}",N[0,0],N[0,1],N[0,2]);
                    Console.WriteLine("{0} {1} {2}",N[1,0],N[1,1],N[1,2]);
                     Console.WriteLine("{0} {1} {2}", N[2, 0], N[2, 1], N[2, 2]);
                     Console.ReadLine();
        }
    }
}

